load "ct_raid_importer.rb"

class CharactersController < ApplicationController
  layout "standard-layout"
  scaffold :character

  before_filter :preload_data

  def index
    redirect_to :action => "list"
  end

  def preload_data
      @races = Race.find(:all)
      @classes = Chrclass.find(:all)
  end

  def new
    @character = Character.new
    #@races = Race.find(:all)
    #@classes = Chrclass.find(:all)
  end

  def list
    @characters = Character.find(:all)
  end

  def create
    #@character = Character.new(@params['chracter_name'])
    @character = Character.new(params[:character])

    if @character.save
        flash[:notice] = "Successfully created character"
        redirect_to :action => 'list'
    else
        flash[:notice] = "Failed to create character"
        render_action "new"
    end
  end

  def show
    @character = Character.find(params[:id])
  rescue
    flash[:error] = 'Error selecting character, redirecting to character list.'
    redirect_to :action => :list
  end
end
